package com.boot.mall.ware.dao;

import com.boot.mall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.boot.mall.ware.vo.SkuStockNum;
import com.boot.mall.ware.vo.SkuWareHasStockVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author huihui
 * @email 2565036109@qq.com
 * @date 2021-05-06 19:36:17
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    Integer hasStock(Long skuId);

    List<SkuStockNum> listSkuHasStockNum(@Param("skuId") Long skuId);

    /**
     * 锁定库存数量，锁定哪个sku在哪一个仓库的多少数量
     * @param skuId
     * @param wareId
     * @param num
     */
    Long lockSkuStock(@Param("skuId") Long skuId,@Param("wareId") Long wareId,@Param("num") Integer num);

    /**
     * 解锁库存
     * @param num
     * @param skuId
     * @param wareId
     * @return
     */
    Long releaseLock(@Param("num") Integer num,@Param("skuId") Long skuId,@Param("wareId") Long wareId);
}
